home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / misctext / vid7_ref / setpx256.asm < prev   
Assembly Source File  |  1990-09-06  |  7KB  |  220 lines

  1.         title    setpx256.asm
  2. comment !
  3.  
  4.  
  5.              (C)opyright 1990 Headland Technology, Inc.
  6.  
  7.                          All Rights Reserved
  8.  
  9.  
  10.          Function: Set Pixel in 256 color super-vga modes         
  11.  
  12.          Supports:
  13.  
  14.      adapter                 resolution      Video 7 mode no  RAM needed
  15.      ----------------------  ----------      ---------------  ----------   
  16.      1024i, VRAM, Fastwrite  640x400x256     66h               256K
  17.      1024i, VRAM, Fastwrite  640x480x256     67h               512K
  18.      VRAM only               720x540x256     68h               512K
  19.      VRAM only               800x600x256     69h               512K                             
  20.  
  21.  
  22.          Prototype: void setpx256( int x, int y, int color,
  23.                          int *bank, int horiz_bytes);
  24.  
  25.                 x - horizontal pixel coordinate
  26.                 y - vertical pixel coordinate
  27.                 color - color to set pixel
  28.                 *bank - current bank location
  29.                 horiz_bytes - number of horizontal pixels
  30.  
  31.  
  32.          Caller: Microsoft Quick C 2.0 or Microsoft C 5.1 Medium Model
  33.                         compiled with MASM 5.1
  34.  
  35.          Returns: void
  36.  
  37.         !
  38.  
  39.         .model    medium, c
  40.  
  41.         .code
  42.                 include gfxlib.inc
  43.         public    setpx256
  44. setpx256    proc    far uses di, x:word, y:word, color:word, active_bank:word, horiz_pixels:word
  45.  
  46.         mov    bl, byte ptr [color]
  47.         mov    cx, [x]
  48.         mov    dx, [y]
  49.  
  50.         mov    ax, GRAPHICS_SEG
  51.                 mov     es, ax
  52.         mov    ax, [horiz_pixels]   ; bytes per scan line
  53.         mul    dx                 ; ds:ax beginning of scan line
  54.         mov    di, ax           
  55.         add    di, cx                 ; es:di   byte
  56.         adc    dx, 0                 ; dx      bank
  57.         mov    cl, bl                 ; cl      color
  58.  ; set bank select 
  59.         cmp    byte ptr [active_bank], dl
  60.         je    done_bank_select
  61.         mov    byte ptr [active_bank], dl
  62.         mov    bl, dl          
  63.         and    bl, 1             ; bl extended page select
  64.         mov    ah, dl
  65.         and    ah, 2
  66.         shl    ah, 1                
  67.         shl    ah, 1
  68.         shl    ah, 1
  69.         shl    ah, 1             ; ah page select bit
  70.         and    dl, 00ch                    
  71.         mov    bh, dl
  72.         shr    dl, 1
  73.         shr    dl, 1
  74.         or    bh, dl             ; bh 256K bank select
  75.         mov    dx, MISC_READ
  76.         in    al, dx             ; get Misc. Output Register
  77.         and    al, not 20h         ; clear page select bit
  78.         or    al, ah             ; set page select bit (maybe)
  79.         mov    dx, MISC_WRITE         ; write Misc. Output Register
  80.         out    dx, al
  81.         mov    dx, SEQUENCER          ; Sequencer
  82.         mov    al, X_PAGE_SELECT    ; extended page select register
  83.         mov    ah, bl             ; extended page select value
  84.         out    dx, ax
  85.         mov    al, X_BANK_SELECT    ; 256K bank select
  86.         out    dx, al        
  87.         inc    dx             ; point to data
  88.         in     al, dx
  89.         and    al, 0f0h          ; clear out bank selects
  90.         or    al, bh             ; set clear bank selects (maybe)
  91.         out    dx, al
  92. done_bank_select:
  93.         mov    es:[di], cl         ; write to memory
  94.         ret
  95. setpx256    endp
  96.         end
  97.  
  98. comment !
  99.                               gfxlib.inc
  100.  
  101.              (C)opyright 1990 Headland Technology, Inc.
  102.  
  103.   This code may be used freely as long as it contains this copyright notice.
  104.  
  105.  
  106.         !
  107.  
  108.  
  109. ;************************************************************************
  110. ;
  111. ;                           Video Buffer Segments
  112. ;
  113.  
  114. GRAPHICS_SEG     equ     0A000h
  115. COLOR_TXT_SEG    equ     0B800h
  116. MONO_TXT_SEG     equ     0B000h
  117.  
  118. ;*************************************************************************
  119. ;
  120. ;                       EGA/VGA Data BIOS Area
  121. ;
  122.  
  123. BIOS_MODE         equ      0449h  ; Current video mode number
  124. BIOS_COLUMNS      equ      044Ah  ; Current number of video columns
  125. BIOS_PAGE_SIZE    equ      044Ch  ; Current size of video buffer
  126. BIOS_PAGE_OFF     equ     044Eh  ; Offset of current video page
  127. BIOS_CURS_POS     equ     0450h  ; Col, row position 
  128. BIOS_CURS_MODE    equ     0460h  ; Current cursor mode setting
  129. BIOS_CURR_PAGE    equ     0462h  ; Current page being displayed
  130. BIOS_6845         equ      0463h  ; Base I/O address for 6845/CRTC
  131. BIOS_CRT_SET      equ     0465h  ; Simulated value of CGA 3x8
  132. BIOS_CRT_PAL      equ     0466h  ; Simulated value of CGA 3x9
  133. BIOS_ROWS         equ     0484h  ; Number of character rows - 1
  134. BIOS_HEIGHT       equ      0485h  ; Bytes per character
  135. BIOS_EQUIP_INFO   equ     0487h  ; Miscellaneous equipment information
  136. BIOS_SWITCHES     equ      0488h  ; Switch settings
  137. BIOS_FLAGS        equ     0489h  ; More VGA info
  138. BIOS_DCC          equ     048A   ; Display combination code
  139.  
  140.  
  141.  
  142.  
  143. ;************************************************************************
  144. ;
  145. ;                      Miscellaneous registers
  146. ;
  147.  
  148. MISC_WRITE        equ     3C2h   ; Miscellaneous Output write
  149. MISC_READ         equ     3CCh   ; Miscellaneous Output read
  150. STATUS            equ     3DAh   ; Status register
  151.  
  152. ;************************************************************************
  153. ;
  154. ;                        Sequencer registers
  155. ;
  156.  
  157. SEQUENCER         equ     3C4h   ; Sequencer index
  158.         RESET     equ     0      ; Reset
  159.         CLOCK     equ     1      ; Clocking mode
  160.         MAPMASK   equ     2      ; Map Mask
  161.         CHARMAP   equ     3      ; Character Map Select
  162.         MODE      equ     4      ; Memory Mode 
  163.  
  164.  
  165. ;***********************************************************************
  166. ;
  167. ;                      CRT Controller registers
  168. ;
  169.  
  170. CRTC              equ     3D4h   ; CRTC index
  171.         OVFL      equ     07h    ; Overflow
  172.         PRS       equ     08h    ; Preset Row scan
  173.         HI_STRT   equ     0Ch    ; Start Address High
  174.         LO_STRT   equ     0Dh    ; Start Address Low
  175.         HI_CPOS   equ     0Eh    ; Cursor Position High
  176.         LO_CPOS   equ     0Fh    ; Cursor Position Low
  177.         VRE       equ     11h    ; Vertical Retrace End
  178.         OFFST     equ     13h    ; Offset
  179.         LCR       equ     14h    ; Line Compare 
  180.  
  181.  
  182. ;***********************************************************************
  183. ;
  184. ;                   Graphics Controller registers
  185. ;
  186.  
  187. GRAPHICS      equ     03CEh   ; Graphics Controller index
  188.         SET_RES   equ     0      ; Set/Reset
  189.         EN_SET    equ     1      ; Enable Set/Reset
  190.         CCMP      equ     2      ; Color Compare
  191.         ROTATE    equ     3      ; Data Rotate
  192.         READMAP   equ     4      ; Read Map Select
  193.         GMODE     equ     5      ; Graphics Mode
  194.         GMISC     equ     6      ; Miscellaneous
  195.         CDONTC    equ     7      ; Color Don't Care
  196.         BITMASK      equ      8      ; Bit Mask
  197.  
  198.  
  199. ;***********************************************************************
  200. ;
  201. ;                   Attribute Controller registers
  202. ;
  203.  
  204. ATTR              equ     3C0h   ; Attribute Controller index
  205.         PALETTE   equ     0      ; 0-15 Palette registers
  206.         AMODE     equ     10h    ; Attribute Mode Control
  207.         OVERSCAN  equ     11h    ; Oversacn Color Register
  208.         PLANE     equ     12h    ; Color Plane Enable
  209.         PAN       equ     13h    ; Horizontal Panning
  210.         COLOR_SEL equ     14h    ; Color Select
  211.  
  212.  
  213. ;*************************************************************************
  214. ;
  215. ;                    Video 7 Extension registers
  216. ;
  217.  
  218. X_BANK_SELECT     equ     0F6h   ; Extended Bank Select
  219. X_PAGE_SELECT     equ     0F9h   ; Extended Page Select
  220.